<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <!--  列表形式展示-->
  <cpn></cpn>
  <!--  水平形式展示-->
  <cpn>
    <!--    目的是获得子组件中的pLanguages-->
    <!--    Vue2.5.x以下必须使用template模板-->
    <template slot-scope="slot">
      <span v-for="item in slot.data">{{item}}——</span>
      <br>
      <span>{{slot.data.join('——')}}</span>
    </template>
  </cpn>
</div>

<template id="cpn">
  <div>
    <slot :data="pLanguages">
      <ul>
        <li v-for="item in pLanguages">{{item}}</li>
      </ul>
    </slot>
    <hr>
  </div>
</template>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
  const app = new Vue({
    el: "#app",
    data: {},
    components: {
      cpn: {
        template: "#cpn",
        data() {
          return {
            pLanguages: ['JavaScript', 'C++', 'Java', 'Python', 'Go', 'Solidity']
          }
        }
      },
    }
  })
</script>
</body>
</html>
